import Types from '../../action/types.js';


const defaultState = {
  authCodeStatus: '',
  authCodeTip: '',
  registStatus: '',
  registTip: '',
};
export default function onAction(state = defaultState, action) {
  switch (action.type) {
    case Types.AUTH_CODE_GET_READY:
      return {
        ...state,
        authCodeStatus: 'ing',
        registStatus: '',
        registTip: '',
      }
      break;
    case Types.AUTH_CODE_GET_SUCCESS:
      return {
        ...state,
        authCodeStatus: 'done',
        authCodeTip: action.authCodeTip,
        registStatus: '',
        registTip: '',
      };
      break;
    case Types.AUTH_CODE_GET_FAIL:
      return {
        ...state,
        authCodeStatus: 'error',
        registStatus: '',
        registTip: '',
        error: action.error,
      };
      break;
    case Types.REGIST_READY:
      return {
        ...state,
        authCodeStatus: '',
        authCodeTip: '',
        registStatus: 'ing'
      };
      break;
    case Types.REGIST_SUCCESS:
      return {
        ...state,
        authCodeStatus: '',
        authCodeTip: '',
        registStatus: action.registStatus,
        registTip: action.registTip
      };
      break;
    case Types.REGIST_FAIL:
      return {
        ...state,
        authCodeStatus: '',
        authCodeTip: '',
        error: action.error
      };
      break;
    default:
      return state
  }
}